package com.laiyizhan.common.mapper;

import com.laiyizhan.common.model.State;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface StateMapper {
    @Delete({
        "delete from state",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into state (hospital, a, ",
        "b, c, d, ",
        "e, f, g)",
        "values (#{hospital,jdbcType=VARCHAR}, #{a,jdbcType=VARCHAR}, ",
        "#{b,jdbcType=VARCHAR}, #{c,jdbcType=VARCHAR}, #{d,jdbcType=VARCHAR}, ",
        "#{e,jdbcType=VARCHAR}, #{f,jdbcType=VARCHAR}, #{g,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(State record);

    int insertSelective(State record);

    @Select({
        "select",
        "id, hospital, a, b, c, d, e, f, g",
        "from state",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    State selectByPrimaryKey(Integer id);

    @Select({
            "select",
            "id, hospital, a, b, c, d, e, f, g",
            "from state",
            "where hospital = #{hospital,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    State selectByName(String hospital);

    int updateByPrimaryKeySelective(State record);

    @Update({
        "update state",
        "set hospital = #{hospital,jdbcType=VARCHAR},",
          "a = #{a,jdbcType=VARCHAR},",
          "b = #{b,jdbcType=VARCHAR},",
          "c = #{c,jdbcType=VARCHAR},",
          "d = #{d,jdbcType=VARCHAR},",
          "e = #{e,jdbcType=VARCHAR},",
          "f = #{f,jdbcType=VARCHAR},",
          "g = #{g,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(State record);


    @Update({
            "update state",
            "set hospital = #{hospital,jdbcType=VARCHAR},",
            "a = #{a,jdbcType=VARCHAR},",
            "b = #{b,jdbcType=VARCHAR},",
            "c = #{c,jdbcType=VARCHAR},",
            "d = #{d,jdbcType=VARCHAR},",
            "e = #{e,jdbcType=VARCHAR},",
            "f = #{f,jdbcType=VARCHAR},",
            "g = #{g,jdbcType=VARCHAR}",
            "where hospital = #{hospital,jdbcType=VARCHAR}"
    })
    int updateByName(State record);
}